/**
 * Created by Administrator on 2018/10/8.
 */
+function ($) {
    var ExtSwitch = function (f, e) {
        this.$element =  $(f);
        this.options = $.extend({}, ExtSwitch.DEFAULTS, e);
        this.init()
    };
    ExtSwitch.DEFAULTS={

    }
    ExtSwitch.prototype.init = function () {
        var element = this.$element,
          options = element.data().options,
          options =  (options && typeof options === 'string') ?options.toObj():options;
          element.bootstrapSwitch(options);
    }
    function Plugin(e) {
        Bolt.assert($.fn.bootstrapSwitch, "依赖组件 iCheck 未引入");
        return this.each(function () {
            var h = $(this);
            var g = h.data("extSwitch");
            var f = typeof e == "object" && e;
            if (!g) {
                h.data("extSwitch", (g = new ExtSwitch(this, f)))
            }
            if (typeof e == "string") {
                g[e]()
            }
        })
    }
    $.fn.extSwitch = Plugin
    $.fn.extSwitch.Constructor = ExtSwitch;

    Bolt.addComponent({
        name: "ExtSwitch",
        plugin: Plugin,
        runPoint: Bolt.eventType.afterAjaxPageShow,
        expr: "input[data-toggle='bootstrapSwitch']",
        order: 800
    })
}(jQuery);